﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace PickGold.Arguments
{
	/// <summary>
	/// 委托调用异常事件参数
	/// </summary>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class CDelegateErrorEventArgs : EventArgs
	{
		private object _Tag;
		private bool _HideError;
		private IDelegate _Handler;
		private Exception _Exception;

		/// <summary>
		/// 构造当前对象类型的一个实例
		/// </summary>
		/// <param name="handler">委托封送对象</param>
		/// <param name="error">委托调用异常</param>
		public CDelegateErrorEventArgs(IDelegate handler, Exception error)
		{
			this._Tag = null;
			this._HideError = false;
			this._Handler = handler;
			this._Exception = error;
		}

		/// <summary>
		/// 构造当前对象类型的一个实例
		/// </summary>
		/// <param name="handler">委托封送对象</param>
		/// <param name="error">委托调用异常</param>
		/// <param name="tag">额外的对象</param>
		public CDelegateErrorEventArgs(IDelegate handler, Exception error, object tag)
		{
			this._Tag = tag;
			this._HideError = false;
			this._Handler = handler;
			this._Exception = error;
		}

		/// <summary>
		/// 委托封送对象
		/// </summary>
		public IDelegate Handler
		{
			get
			{
				return this._Handler;
			}
		}

		/// <summary>
		/// 委托调用异常对象
		/// </summary>
		public Exception Error
		{
			get
			{
				return this._Exception;
			}
		}

		/// <summary>
		/// 是否应该隐藏错误
		/// </summary>
		public bool HideError
		{
			set
			{
				this._HideError = value;
			}
			get
			{
				return this._HideError;
			}
		}

		/// <summary>
		/// 额外的对象
		/// </summary>
		public object Tag
		{
			set
			{
				this._Tag = value;
			}
			get
			{
				return this._Tag;
			}
		}
	}
}
